using System;
using System.Collections.Generic;
using System.Text;
using System.Reflection;

namespace GwtRpcNet.Rpc
{
    public class RpcNetRequest
    {
        #region Members

        private int version;

        public int Version
        {
            get { return version; }
            set { version = value; }
        }
        private int flags;

        public int Flags
        {
            get { return flags; }
            set { flags = value; }
        }
        private string serviceUrl;

        public string ServiceUrl
        {
            get { return serviceUrl; }
            set { serviceUrl = value; }
        }
        private string strongService;

        public string StrongService
        {
            get { return strongService; }
            set { strongService = value; }
        }
        private string serviceTypeName;

        public string ServiceTypeName
        {
            get { return serviceTypeName; }
            set { serviceTypeName = value; }
        }

        private Type serviceType;
        public Type ServiceType
        {
            get 
            {
                if (serviceType == null)
                    serviceType = RpcNet.GetTypeForName(ServiceTypeName);
                return serviceType; 
            }
            set { serviceType = value; }
        }

        private string serviceMethodName;

        public string ServiceMethodName
        {
            get { return serviceMethodName; }
            set { serviceMethodName = value; }
        }
        private Type[] serviceParamTypes;

        public Type[] ServiceParamTypes
        {
            get { return serviceParamTypes; }
            set { serviceParamTypes = value; }
        }
        private object[] serviceParamValues;

        public object[] ServiceParamValues
        {
            get { return serviceParamValues; }
            set { serviceParamValues = value; }
        }

        #endregion

        public RpcNetRequest()
        {

        }

        public object GetService()
        {
            return Activator.CreateInstance(ServiceType);
        }

        public MethodInfo GetServiceMethod()
        {
            MethodInfo method = ServiceType.GetMethod(ServiceMethodName, serviceParamTypes);
            return method;
        }
    }
}
